import CryptoJS from 'crypto-js'

const key = 'AAgtdsj1gCEBbiGCxIjOD3ka7UnWX677' // 16字节或32字节密钥

const iv = "NdjuPSYo56V4VZxY"


export const encrypt = (data:string) => {
	try{
		const keyWA = CryptoJS.enc.Utf8.parse(key)
		const ivWA = CryptoJS.enc.Utf8.parse(iv)
		return CryptoJS.AES.encrypt(data, keyWA, {
			iv: ivWA,
			mode: CryptoJS.mode.CBC,
			padding: CryptoJS.pad.Pkcs7
		}).toString()
	} catch(e){
		console.log('加密失败',e)
	}
}